home *** CD-ROM | disk | FTP | other *** search
/ Aminet 43 / Aminet 43 (2001)(GTI - Schatztruhe)[!][Jun 2001].iso / Aminet / comm / tcp / Amster-source.lha / Amster_Install / Source / include / mui.h < prev    next >
C/C++ Source or Header  |  2000-12-31  |  10KB  |  239 lines

  1. /*
  2. ** MUI Helper Header of MadCat!
  3. */
  4.  
  5. #ifndef AMSTER_MUI_H
  6. #define AMSTER_MUI_H
  7.  
  8. #include <proto/exec.h>
  9. #include <proto/utility.h>
  10. #include <proto/intuition.h>
  11. #include <libraries/mui.h>
  12. #include <proto/muimaster.h>
  13. #include <clib/alib_protos.h>
  14.  
  15. #include "compiler.h"
  16.  
  17. #ifdef __MORPHOS__
  18. #undef MUI_NewObject
  19. #define DoMethod(MyObject, tags...) \
  20.     ({ULONG _tags[] = { tags }; DoMethodA((MyObject), (APTR)_tags);})
  21. #define DoSuperMethod(MyClass, MyObject, tags...) \
  22.     ({ULONG _tags[] = { tags }; DoSuperMethodA((MyClass), (MyObject), (APTR)_tags);})
  23. #define CoerceMethod(MyClass, MyObject, tags...) \
  24.     ({ULONG _tags[] = { tags }; CoerceMethodA((MyClass), (MyObject), (APTR)_tags);})
  25. #endif    /* __MORPHOS__ */
  26.  
  27. #define MUIM_Window_Cleanup       0x8042ab26 /* Custom Class */ /* V18 */
  28. #define MUIM_Window_Setup         0x8042c34c /* Custom Class */ /* V18 */
  29.  
  30. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  31.  
  32. #ifdef __MORPHOS__
  33. static void putChar_gate(void);
  34. static struct EmulLibEntry putChar =
  35. {
  36.     TRAP_LIB, 0, (void (*)(void)) putChar_gate
  37. };
  38. #else
  39. void SAVEDS ASM putChar(REG(a0, struct Hook *hook), REG(a1, char c), REG(a2, struct Locale *locale));
  40. #endif
  41.  
  42. #ifdef __MORPHOS__
  43. ULONG DoSuperNew(struct IClass *cl, Object *obj, ...);
  44. #else
  45. ULONG __stdargs DoSuperNew(struct IClass *cl, Object *obj, ULONG tag1, ...);
  46. #endif
  47.  
  48. typedef struct muimsg_struct {
  49.     ULONG MethodID;
  50.     ULONG *arg1;
  51.     ULONG *arg2;
  52.     ULONG *arg3;
  53.     ULONG *arg4;
  54. } *muimsg;
  55.  
  56. Object *maketmenu(const UBYTE *msg);
  57. Object *makemenu(const UBYTE *msg);
  58. Object *maketoggle(const UBYTE *msg, Object **tog);
  59. void SPrintF(char *outstr, char *fmtstr, ...);
  60.  
  61. typedef struct
  62. {
  63.     char *supername;
  64.     int datasize;
  65.     APTR dispatcher;
  66.     struct MUI_CustomClass **ptr;
  67. } muiclass;
  68.  
  69. int mui_classes_setup(muiclass mcl[]);
  70. void mui_classes_cleanup(muiclass mcl[]);
  71.  
  72.  
  73.  
  74. /* Following macros makes your hooks compatible with sas/c, gcc, and gcc-morphos */
  75.  
  76. #ifdef __MORPHOS__
  77. #define MUI_HOOK_DECL(x,y,z) struct EmulLibEntry x
  78. #define MUI_HOOK(x,y,z) \
  79.     static ULONG SAVEDS x ## _gate(void); \
  80.     static ULONG x ## _gate2(struct Hook *hook, y , z ); \
  81.     struct EmulLibEntry x = { \
  82.     TRAP_LIB, 0, (void (*)(void)) x ## _gate }; \
  83.     static ULONG SAVEDS x ## _gate(void) { \
  84.     return ( x ## _gate2((void *)REG_A0, (void *)REG_A2, (void *)REG_A1)); } \
  85.     static ULONG x ## _gate2(struct Hook *hook, y , z )
  86. #define MUI_HOOK_STATIC(x,y,z) \
  87.     static ULONG SAVEDS x ## _gate(void); \
  88.     static ULONG x ## _gate2(struct Hook *hook, y , z ); \
  89.     static struct EmulLibEntry x = { \
  90.     TRAP_LIB, 0, (void (*)(void)) x ## _gate }; \
  91.     static ULONG SAVEDS x ## _gate(void) { \
  92.     return ( x ## _gate2((void *)REG_A0, (void *)REG_A2, (void *)REG_A1)); } \
  93.     static ULONG x ## _gate2(struct Hook *hook, y , z )
  94.  
  95. #define MUI_DISPATCH_DECL(x) struct EmulLibEntry x
  96. #define MUI_DISPATCH(x) \
  97.     static ULONG SAVEDS x ## _gate(void); \
  98.     static ULONG x ## _gate2(struct IClass *cl, Object *obj, Msg msg); \
  99.     struct EmulLibEntry x = { \
  100.     TRAP_LIB, 0, (void (*)(void)) x ## _gate }; \
  101.     static ULONG SAVEDS x ## _gate(void) { \
  102.     return ( x ## _gate2((void *)REG_A0, (void *)REG_A2, (void *)REG_A1)); } \
  103.     static ULONG x ## _gate2(struct IClass *cl, Object *obj, Msg msg)
  104. #define MUI_DISPATCH_STATIC(x) \
  105.     static ULONG SAVEDS x ## _gate(void); \
  106.     static ULONG x ## _gate2(struct IClass *cl, Object *obj, Msg msg); \
  107.     static struct EmulLibEntry x = { \
  108.     TRAP_LIB, 0, (void (*)(void)) x ## _gate }; \
  109.     static ULONG SAVEDS x ## _gate(void) { \
  110.     return ( x ## _gate2((void *)REG_A0, (void *)REG_A2, (void *)REG_A1)); } \
  111.     static ULONG x ## _gate2(struct IClass *cl, Object *obj, Msg msg)
  112.  
  113. #define MUI_LIST_DISP_DECL(x,y) struct EmulLibEntry x
  114. #define MUI_LIST_DISP(x,y) \
  115.     static ULONG SAVEDS x ## _gate(void); \
  116.     static ULONG x ## _gate2(char **array, y ); \
  117.     struct EmulLibEntry x = { \
  118.     TRAP_LIB, 0, (void (*)(void)) x ## _gate }; \
  119.     static ULONG SAVEDS x ## _gate(void) { \
  120.     return ( x ## _gate2((void *)REG_A2, (void *)REG_A1)); } \
  121.     static ULONG x ## _gate2(char **array, y )
  122. #define MUI_LIST_DISP_STATIC(x,y) \
  123.     static ULONG SAVEDS x ## _gate(void); \
  124.     static ULONG x ## _gate2(char **array, y ); \
  125.     static struct EmulLibEntry x = { \
  126.     TRAP_LIB, 0, (void (*)(void)) x ## _gate }; \
  127.     static ULONG SAVEDS x ## _gate(void) { \
  128.     return ( x ## _gate2((void *)REG_A2, (void *)REG_A1)); } \
  129.     static ULONG x ## _gate2(char **array, y )
  130.  
  131. #define MUI_LIST_CONS_DECL(x,y) struct EmulLibEntry x
  132. #define MUI_LIST_CONS(x,y) \
  133.     static ULONG SAVEDS x ## _gate(void); \
  134.     static ULONG x ## _gate2(APTR pool, y ); \
  135.     struct EmulLibEntry x = { \
  136.     TRAP_LIB, 0, (void (*)(void)) x ## _gate }; \
  137.     static ULONG SAVEDS x ## _gate(void) { \
  138.     return ( x ## _gate2((void *)REG_A2, (void *)REG_A1)); } \
  139.     static ULONG x ## _gate2(APTR pool, y )
  140. #define MUI_LIST_CONS_STATIC(x,y) \
  141.     static ULONG SAVEDS x ## _gate(void); \
  142.     static ULONG x ## _gate2(APTR pool, y ); \
  143.     static struct EmulLibEntry x = { \
  144.     TRAP_LIB, 0, (void (*)(void)) x ## _gate }; \
  145.     static ULONG SAVEDS x ## _gate(void) { \
  146.     return ( x ## _gate2((void *)REG_A2, (void *)REG_A1)); } \
  147.     static ULONG x ## _gate2(APTR pool, y )
  148.  
  149. #define MUI_LIST_DEST_DECL(x,y) struct EmulLibEntry x
  150. #define MUI_LIST_DEST(x,y) \
  151.     static ULONG SAVEDS x ## _gate(void); \
  152.     static ULONG x ## _gate2(APTR pool, y ); \
  153.     struct EmulLibEntry x = { \
  154.     TRAP_LIB, 0, (void (*)(void)) x ## _gate }; \
  155.     static ULONG SAVEDS x ## _gate(void) { \
  156.     return ( x ## _gate2((void *)REG_A2, (void *)REG_A1)); } \
  157.     static ULONG x ## _gate2(APTR pool, y )
  158. #define MUI_LIST_DEST_STATIC(x,y) \
  159.     static ULONG SAVEDS x ## _gate(void); \
  160.     static ULONG x ## _gate2(APTR pool, y ); \
  161.     static struct EmulLibEntry x = { \
  162.     TRAP_LIB, 0, (void (*)(void)) x ## _gate }; \
  163.     static ULONG SAVEDS x ## _gate(void) { \
  164.     return ( x ## _gate2((void *)REG_A2, (void *)REG_A1)); } \
  165.     static ULONG x ## _gate2(APTR pool, y )
  166.  
  167. #define MUI_LIST_COMP_DECL(x,y,z) struct EmulLibEntry x
  168. #define MUI_LIST_COMP(x,y,z) \
  169.     static ULONG SAVEDS x ## _gate(void); \
  170.     static ULONG x ## _gate2( y , z ); \
  171.     struct EmulLibEntry x = { \
  172.     TRAP_LIB, 0, (void (*)(void)) x ## _gate }; \
  173.     static ULONG SAVEDS x ## _gate(void) { \
  174.     return ( x ## _gate2((void *)REG_A1, (void *)REG_A2)); } \
  175.     static ULONG x ## _gate2( y , z )
  176. #define MUI_LIST_COMP_STATIC(x,y,z) \
  177.     static ULONG SAVEDS x ## _gate(void); \
  178.     static ULONG x ## _gate2( y , z ); \
  179.     static struct EmulLibEntry x = { \
  180.     TRAP_LIB, 0, (void (*)(void)) x ## _gate }; \
  181.     static ULONG SAVEDS x ## _gate(void) { \
  182.     return ( x ## _gate2((void *)REG_A1, (void *)REG_A2)); } \
  183.     static ULONG x ## _gate2( y , z )
  184.  
  185. #define MUI_NLIST_COMP_DECL(x) struct EmulLibEntry x
  186. #define MUI_NLIST_COMP(x) \
  187.     static ULONG SAVEDS x ## _gate(void); \
  188.     static ULONG x ## _gate2(struct Hook *hook, Object *obj, struct NList_CompareMessage *ncm); \
  189.     struct EmulLibEntry x = { \
  190.     TRAP_LIB, 0, (void (*)(void)) x ## _gate }; \
  191.     static ULONG SAVEDS x ## _gate(void) { \
  192.     return ( x ## _gate2((void *)REG_A0, (void *)REG_A2, (void *)REG_A1)); } \
  193.     static ULONG x ## _gate2(struct Hook *hook, Object *obj, struct NList_CompareMessage *ncm)
  194.  
  195. #define MUI_APPMSG_DECL(x) struct EmulLibEntry x
  196. #define MUI_APPMSG(x) \
  197.     static ULONG SAVEDS x ## _gate(void); \
  198.     static ULONG x ## _gate2(APTR obj, struct AppMessage **lala); \
  199.     struct EmulLibEntry x = { \
  200.     TRAP_LIB, 0, (void (*)(void)) x ## _gate }; \
  201.     static ULONG SAVEDS x ## _gate(void) { \
  202.     return ( x ## _gate2((void *)REG_A2, (void *)REG_A1)); } \
  203.     static ULONG x ## _gate2(APTR obj, struct AppMessage **appmsg)
  204.  
  205. #else
  206. #define MUI_HOOK_DECL(x,y,z) ULONG SAVEDS ASM x (REG(a0,struct Hook *hook), REG(a2, y ), REG(a1, z ))
  207. #define MUI_HOOK(x,y,z) ULONG SAVEDS ASM x (REG(a0,struct Hook *hook), REG(a2, y ), REG(a1, z ))
  208. #define MUI_HOOK_STATIC(x,y,z) static ULONG SAVEDS ASM x (REG(a0,struct Hook *hook), REG(a2, y ), REG(a1, z ))
  209.  
  210. #define MUI_DISPATCH_DECL(x) ULONG SAVEDS ASM x (REG(a0,struct IClass *cl), REG(a2,Object *obj), REG(a1,Msg msg))
  211. #define MUI_DISPATCH(x) ULONG SAVEDS ASM x (REG(a0,struct IClass *cl), REG(a2,Object *obj), REG(a1,Msg msg))
  212.  
  213. #define MUI_LIST_DISP_DECL(x,y) ULONG SAVEDS ASM x (REG(a2,char **array), REG(a1, y ))
  214. #define MUI_LIST_DISP(x,y) ULONG SAVEDS ASM x (REG(a2,char **array), REG(a1, y ))
  215. #define MUI_LIST_DISP_STATIC(x,y) static ULONG SAVEDS ASM x (REG(a2,char **array), REG(a1, y ))
  216.  
  217. #define MUI_LIST_CONS_DECL(x,y) ULONG SAVEDS ASM x (REG(a2,APTR pool), REG(a1, y ))
  218. #define MUI_LIST_CONS(x,y) ULONG SAVEDS ASM x (REG(a2,APTR pool), REG(a1, y ))
  219. #define MUI_LIST_CONS_STATIC(x,y) static ULONG SAVEDS ASM x (REG(a2,APTR pool), REG(a1, y ))
  220.  
  221. #define MUI_LIST_DEST_DECL(x,y) ULONG SAVEDS ASM x (REG(a2,APTR pool), REG(a1, y ))
  222. #define MUI_LIST_DEST(x,y) ULONG SAVEDS ASM x (REG(a2,APTR pool), REG(a1, y ))
  223. #define MUI_LIST_DEST_STATIC(x,y) static ULONG SAVEDS ASM x (REG(a2,APTR pool), REG(a1, y ))
  224.  
  225. #define MUI_LIST_COMP_DECL(x,y,z) LONG SAVEDS ASM x (REG(a1, y ), REG(a2, z ))
  226. #define MUI_LIST_COMP(x,y,z) LONG SAVEDS ASM x (REG(a1, y ), REG(a2, z ))
  227. #define MUI_LIST_COMP_STATIC(x,y,z) static LONG SAVEDS ASM x (REG(a1, y ), REG(a2, z ))
  228.  
  229. #define MUI_NLIST_COMP_DECL(x) ULONG SAVEDS ASM x (REG(a0,struct Hook *hook), REG(a2,Object *obj), REG(a1, struct NList_CompareMessage *ncm))
  230. #define MUI_NLIST_COMP(x) ULONG SAVEDS ASM x (REG(a0,struct Hook *hook), REG(a2,Object *obj), REG(a1, struct NList_CompareMessage *ncm))
  231.  
  232. #define MUI_APPMSG_DECL(x) ULONG SAVEDS ASM x (REG(a2,APTR obj), REG(a1,struct AppMessage **appmsg))
  233. #define MUI_APPMSG(x) ULONG SAVEDS ASM x (REG(a2,APTR obj), REG(a1,struct AppMessage **appmsg))
  234. #endif
  235.  
  236.  
  237.  
  238. #endif    /* AMSTER_MUI_H */
  239.